import unittest
from unittest.mock import Mock, patch
from backup.full_backup import FullBackupEngine

class TestFullBackup(unittest.TestCase):
    @patch('shared.graph_client.GraphClient')
    def test_full_backup_process(self, mock_graph):
        # 配置mock
        mock_client = mock_graph.return_value
        mock_client.paginate.return_value = [{
            "id": "msg1",
            "subject": "Test",
            "body": {"content": "Hello World"},
            "receivedDateTime": "2023-01-01T00:00:00Z"
        }]
        
        # 执行备份
        storage = Mock()
        engine = FullBackupEngine(mock_client, storage)
        backup_id = engine.backup_mailbox("user1")
        
        # 验证结果
        self.assertIsNotNone(backup_id)
        storage.store.assert_called_once()
        
    @patch('shared.crypto.AESCipher')
    def test_encryption(self, mock_crypto):
        mock_cipher = mock_crypto.return_value
        mock_cipher.encrypt.return_value = b"encrypted_data"
        
        data = b"test_data"
        encrypted = mock_cipher.encrypt(data)
        
        self.assertEqual(encrypted, b"encrypted_data")
        mock_cipher.encrypt.assert_called_once_with(data)